package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	NeedStatusEventNew           = "erp.NeedStatusNew"
	NeedStatusEventBeforeCreate  = "erp.NeedStatusBeforeCreate"
	NeedStatusEventBeforeUpdate  = "erp.NeedStatusBeforeUpdate"
	NeedStatusEventBeforeSave    = "erp.NeedStatusBeforeCreate erp.NeedStatusBeforeUpdate"
	NeedStatusEventAfterCreate   = "erp.NeedStatusAfterCreate"
	NeedStatusEventAfterUpdate   = "erp.NeedStatusAfterUpdate"
	NeedStatusEventAfterSave     = "erp.NeedStatusAfterCreate erp.NeedStatusAfterUpdate"
	NeedStatusEventDelete        = "erp.NeedStatusDelete"
	NeedStatusAccessControlEvent = "erp.NeedStatusAccessControl"
)

func GetNeedStatusConfig() *mgo.DocConfig {
	return NeedStatus_Config
}

var NeedStatus_Config *mgo.DocConfig

func init() {
	NeedStatus_Config = NewNeedStatusConfig()
}
func NewNeedStatusConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.NeedStatus",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children", "color", "background", "group", "step", "warn",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetNeedStatusConfig,
				DocName:    "NeedStatus",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetNeedStatusConfig,
				DocName:    "NeedStatus",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
